home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 076-100 / 079 / uw / serial.c < prev    next >
C/C++ Source or Header  |  1995-03-13  |  3KB  |  96 lines

  1. #include "exec/types.h"
  2. #include "exec/ports.h"
  3. #include "exec/devices.h"
  4. #include "exec/io.h"
  5. #include "exec/memory.h"
  6. #include "devices/serial.h"
  7.  
  8. /* Open a serial device */
  9.       int
  10. OpenSerial(readrequest,writerequest)
  11.       struct IOExtSer *readrequest;
  12.       struct IOExtSer *writerequest;
  13.       {
  14.             int error;
  15.             readrequest->io_SerFlags = NULL;
  16.             error = OpenDevice(SERIALNAME, NULL, readrequest, NULL);
  17.             writerequest->IOSer.io_Device = readrequest->IOSer.io_Device;
  18.             writerequest->IOSer.io_Unit = readrequest->IOSer.io_Unit;
  19.             writerequest->io_CtlChar = readrequest->io_CtlChar;
  20.             writerequest->io_ReadLen = readrequest->io_ReadLen;
  21.             writerequest->io_BrkTime = readrequest->io_BrkTime;
  22.             writerequest->io_Baud = readrequest->io_Baud;
  23.             writerequest->io_WriteLen = readrequest->io_WriteLen;
  24.             writerequest->io_StopBits = readrequest->io_StopBits;
  25.             writerequest->io_RBufLen = readrequest->io_RBufLen;
  26.             writerequest->io_SerFlags = readrequest->io_SerFlags;
  27.             writerequest->io_TermArray.TermArray0
  28.             = readrequest->io_TermArray.TermArray0;
  29.             writerequest->io_TermArray.TermArray1
  30.             = readrequest->io_TermArray.TermArray1;
  31.             /* clone required parts of the request */
  32.             return(error);
  33.       }
  34.  
  35.       int
  36. SerPutChar(request,character)
  37.       struct IOExtSer *request;
  38.       char character;
  39.       {
  40.             request->IOSer.io_Command = CMD_WRITE;
  41.             request->IOSer.io_Data = (APTR)&character;
  42.             request->IOSer.io_Length = 1;
  43.             DoIO(request);
  44.             return(0);
  45.       }
  46.  
  47.       int
  48. QueueSerRead(request, whereto)
  49.       struct IOExtSer *request;
  50.       char *whereto;
  51.       {
  52.             request->IOSer.io_Command = CMD_READ;
  53.             request->IOSer.io_Data = (APTR)whereto;
  54. /*            request->IOSer.io_Flags = IOF_QUICK; */
  55.             request->IOSer.io_Length = 1;
  56.             BeginIO(request);
  57.             return(0);
  58.       }
  59.  
  60.       int
  61. QuerySer(request)
  62.     struct IOExtSer *request;
  63.     {
  64.         request->IOSer.io_Command = SDCMD_QUERY;
  65.         BeginIO(request);
  66.         WaitIO(request);
  67. /*        DoIO(request); */
  68.         return((int)(request->IOSer.io_Actual));
  69.     } /* end of QuerySer */
  70.  
  71.    int
  72. SetParams(io,rbuf_len,rlen,wlen,brk,baud,sf,ta0,ta1)
  73.    struct IOExtSer *io;
  74.    unsigned long rbuf_len;
  75.    unsigned char rlen;
  76.    unsigned char wlen;
  77.    unsigned long brk;
  78.    unsigned long baud;
  79.    unsigned char sf;
  80.    unsigned long ta0;
  81.    unsigned long ta1;
  82.    {
  83.       io->io_ReadLen = rlen;
  84.       io->io_WriteLen = wlen;
  85.       io->io_Baud = baud;
  86.       io->io_BrkTime = brk;
  87.       io->io_StopBits = 0x01;
  88.       io->io_RBufLen = rbuf_len;
  89.       io->io_SerFlags = sf;
  90.       io->io_TermArray.TermArray0 = ta0;
  91.       io->io_TermArray.TermArray1 = ta1;
  92.       io->IOSer.io_Command = SDCMD_SETPARAMS;
  93.    
  94.       return(DoIO(io));
  95. }
  96.